﻿using MATtutsLab.Entities;
using MATtutsLab.MVP.Presenters;
using MATtutsLab.MVP.Views;
using MATtutsLab.Repositories;
using NUnit.Framework;
using Rhino.Mocks;

namespace MATtutsLab.Specs
{
    public abstract class ZombieMovieDetailsPresenterSpecsContext
    {
        protected IZombieMovieDetailsView View;
        protected ZombieMovieDetailsPresenter Presenter;
        protected IMovieRepository Repository;

        [TestFixtureSetUp]
        protected virtual void Context()
        {
            View = MockRepository.GenerateMock<IZombieMovieDetailsView>();
            Repository = MockRepository.GenerateMock<IMovieRepository>();

            Presenter = new ZombieMovieDetailsPresenter(View, Repository);
        }
    }

    public class When_initializing_details_view : ZombieMovieDetailsPresenterSpecsContext
    {
        protected override void Context()
        {
            base.Context();

            Presenter.InitializeView(new Movie());
        }

        [Test]
        public void Should_display_selected_movie_details()
        {
            View.AssertWasCalled(view => view.DisplayMovieDetails(null), options => options.IgnoreArguments());
        }
    }

    public class When_requesting_to_close_form : ZombieMovieDetailsPresenterSpecsContext
    {
        protected override void Context()
        {
            base.Context();

            Presenter.CloseRequested();
        }

        [Test]
        public void Should_close_form()
        {
            View.AssertWasCalled(view => view.CloseForm());
        }
    }
}
